﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="LedgerGroup.aspx.cs" Inherits="Main_Group_LedgerGroup"
    EnableEventValidation="false" %>

<%@ Register Src="~/User Controls/PageHeading.ascx" TagName="heading" TagPrefix="acc" %>
<%@ Register Src="~/User Controls/CommonControls.ascx" TagName="CommonControls" TagPrefix="MyControls" %>
<%@ Register Src="~/User Controls/Pager.ascx" TagPrefix="custom" TagName="Pager" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Ledger Group</title>
    <link href="../../Styles/accounts.css" rel="Stylesheet" type="text/css" />

    <script type="text/javascript">
        function Validations() {
            var flag = true;
            if (document.getElementById("txtGroup").value == '') {
                alert('Specify Group Name !');
                flag = false;
                document.getElementById("txtGroup").focus();
            }
            else if (document.getElementById("ddlParentGroup").value == '-1') {
                alert('Specify Parent Group !');
                flag = false;
                document.getElementById("ddlParentGroup").focus();
            }
            return flag;
        }
        
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="sm" runat="server">
    </asp:ScriptManager>
    <div>
        <asp:UpdatePanel ID="updPanel" runat="server">
            <Triggers>
                <asp:PostBackTrigger ControlID="CommonControls2" />
            </Triggers>
            <ContentTemplate>
                <div class="divmain">
                    <acc:heading ID="pagehead" runat="server" HeadingText="Ledger Group" />
                    <div style="text-align: center; height: 20px; width: 50%; margin-left: 22%; margin-right: 25%">
                        <asp:Label ID="lblMsg" runat="server" Font-Bold="true" EnableViewState="false"></asp:Label></div>
                    <asp:Panel ID="PnlAddNew" runat="server" Visible="false">
                        <table class="tablecontent" style="width: 50%; margin-left: 25%; margin-right: 25%;
                            border: 1px solid #818181;">
                            <tr>
                                <td class="headtd" colspan="2">
                                    Ledger Group Details
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 40%">
                                    Group Name<span style="color: Red">*</span>
                                </td>
                                <td style="width: 60%">
                                    <asp:TextBox ID="txtGroup" ToolTip="Group Name" runat="server" CssClass="input" Width="70%">
                                        
                                    </asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Alternate Group Name
                                </td>
                                <td>
                                    <asp:TextBox ID="txtAltGroup" ToolTip="Alternate Group Name" runat="server" CssClass="input"
                                        Width="70%"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Parent Group Name<span style="color: Red">*</span>
                                </td>
                                <td>
                                    <asp:DropDownList ID="ddlParentGroup" CssClass="dropdown" runat="server" Width="72%">
                                    </asp:DropDownList>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                </td>
                                <td>
                                    <asp:Button ID="btnSubmit" runat="server" Text="Submit" CssClass="button" OnClick="btnSubmit_Click" OnClientClick="return Validations();" />&nbsp;<asp:Button
                                        ID="btnCancel" runat="server" Text="Cancel" CssClass="button" OnClick="btnCancel_Click" />
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                    <asp:Panel ID="PnlView" runat="server" Visible="false">
                        <div style="width: 100%; margin-left: 5%; margin-right: 5%; margin-top: 15px">
                            <div style="padding-top: 15px; padding-bottom: 5px; margin-left: 30%;">
                                <div style="float: left;">
                                    <custom:Pager ID="custPager" runat="server" OnPageChanged="custPager_PageChanged" />
                                </div>
                                <div style="float: left; margin-left: 10px;">
                                    <MyControls:CommonControls ID="CommonControls2" runat="server" GridviewControlId="grdDisplay"
                                        HideColumns="5" />
                                </div>
                            </div>
                            <div id="divprint" runat="server">
                                <asp:GridView ID="grdDisplay" runat="server" CssClass="gridview" Width="90%" AutoGenerateColumns="False"
                                    AllowPaging="True" RowStyle-CssClass="gridviewitem" PagerStyle-CssClass="pgr"
                                    OnPageIndexChanging="grdDisplay_PageIndexChanging" AlternatingRowStyle-CssClass="gridview_alternate"
                                    OnRowDataBound="grdDisplay_RowDataBound" OnRowCancelingEdit="grdDisplay_RowCancelingEdit"
                                    OnRowEditing="grdDisplay_RowEditing" OnRowUpdating="grdDisplay_RowUpdating" DataKeyNames="gid"
                                    OnRowCreated="grdDisplay_RowCreated">
                                    <Columns>
                                        <asp:TemplateField HeaderText="S.NO." ItemStyle-HorizontalAlign="Center">
                                            <ItemTemplate>
                                                <%#Container.DataItemIndex+1%>
                                            </ItemTemplate>
                                            <ItemStyle HorizontalAlign="Center" />
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Group Name">
                                            <ItemTemplate>
                                                <%#Eval("Gname") %>
                                            </ItemTemplate>
                                            <EditItemTemplate>
                                                <asp:TextBox ID="txtEditGname" CssClass="input" runat="server" Text=' <%#Eval("Gname") %>' ValidationGroup="V"></asp:TextBox>
                                                <asp:RequiredFieldValidator ID="reqEditGname" runat="server" ControlToValidate="txtEditGname"
                                                    ErrorMessage="*" ValidationGroup="V" Display="Dynamic"></asp:RequiredFieldValidator>
                                            </EditItemTemplate>
                                        </asp:TemplateField>
                                         <asp:TemplateField HeaderText="Alt. Group Nam">
                                            <ItemTemplate>
                                                <%#Eval("GANAME") %>
                                            </ItemTemplate>
                                            <EditItemTemplate>
                                                <asp:TextBox ID="txtEditAltGname" CssClass="input" runat="server" Text=' <%#Eval("GANAME") %>' ValidationGroup="V"></asp:TextBox>                                                
                                            </EditItemTemplate>
                                        </asp:TemplateField>                                        
                                        <asp:TemplateField HeaderText="Parent Group Name">
                                            <ItemTemplate>
                                                <%#Eval("PNAME") %>
                                            </ItemTemplate>
                                            <EditItemTemplate>
                                                <asp:DropDownList ID="ddlEditParent" CssClass="dropdown" runat="server" 
                                                    Width="150px">
                                                </asp:DropDownList>
                                                <asp:RequiredFieldValidator ID="reqDDLParent" runat="server" ControlToValidate="ddlEditParent"
                                                    ErrorMessage="*" ValidationGroup="V" InitialValue="-1" Display="Dynamic"></asp:RequiredFieldValidator>
                                                <asp:HiddenField ID="HidPid" runat="server" Value='<%# Eval("PID") %>' />
                                            </EditItemTemplate>
                                        </asp:TemplateField>
                                        <asp:BoundField DataField="PREDEFINED" HeaderText="Predefined" ReadOnly="true" ItemStyle-HorizontalAlign="Center">
                                            <ItemStyle HorizontalAlign="Center" />
                                        </asp:BoundField>
                                        <asp:CommandField HeaderText="Edit Group" EditText="<img src='../../Menu/images/Edit_user.png' alt='Edit'>"
                                            ShowEditButton="true" UpdateText="<img src='../../Menu/images/update.png' alt='Update'>"
                                            CancelText="<img src='../../Menu/images/cancel.png' alt='Cancel'>" ItemStyle-HorizontalAlign="Center"
                                            ValidationGroup="V">
                                            <ItemStyle HorizontalAlign="Center" />
                                        </asp:CommandField>
                                    </Columns>
                                    <PagerStyle HorizontalAlign="Right" />
                                </asp:GridView>
                            </div>
                        </div>
                    </asp:Panel>
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    </form>
</body>
</html>
